﻿using System.Collections.ObjectModel;
using G.Model;
using G.Model.Runtime;

namespace G.Runtime
{
    public class GameTasks : KeyedCollection<string, GameTask>, HasGameSpace
    {
        private GameTaskDefs _GameTaskDefs;
        private GameSpace _Game;

        internal GameTasks(GameTaskDefs pGameTaskDefs, GameSpace pGame)
        {
            _Game = pGame;
            _GameTaskDefs = pGameTaskDefs;
        }

        public GameTask Add(GameTaskDef def)
        {
            GameTask e = new GameTask(def, _Game);
            base.Add(e);
            return e;
        }
        
        public GameSpace Game
        {
            get { return _Game; }
        }

        protected override string GetKeyForItem(GameTask item)
        {
            return item.Def.Name;
        }

    }
}
